-
Notifications
You must be signed in to change notification settings - Fork 34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
feat(headless): Support the automatic query correction feature for the insight use case #4598
base: master
Are you sure you want to change the base?
Conversation
Pull Request ReportPR Title❌ Title should follow the conventional commit spec: Example: Live demo linksBundle Size
SSR Progress
Detailed logssearch : buildInteractiveResultsearch : buildInteractiveInstantResult search : buildInteractiveRecentResult search : buildInteractiveCitation search : buildGeneratedAnswer recommendation : missing SSR support case-assist : missing SSR support insight : missing SSR support commerce : missing SSR support |
packages/headless/src/features/insight-search/insight-search-actions-thunk-processor.ts
Outdated
Show resolved
Hide resolved
packages/headless/src/features/insight-search/insight-search-request.test.ts
Outdated
Show resolved
Hide resolved
2f43038
to
3d08c8a
Compare
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The thing missing to support the modern way of providing the query correct feature in the insight use case is the modification needed to the insight did you mean controller.
It currently does not expose any options to choose the the mode to be used, this need to be added to fully suppor this feature in the Headless library.
You can take this controller as an example:
ui-kit/packages/headless/src/controllers/did-you-mean/headless-did-you-mean.ts
Lines 39 to 43 in d823590
export function buildDidYouMean( | |
engine: SearchEngine, | |
props: DidYouMeanProps = {} | |
): DidYouMean { | |
const controller = buildCoreDidYouMean(engine, props); |
packages/headless/src/features/insight-search/insight-search-actions-thunk-processor.test.ts
Show resolved
Hide resolved
packages/headless/src/features/insight-search/insight-search-actions-thunk-processor.test.ts
Outdated
Show resolved
Hide resolved
packages/headless/src/features/insight-search/insight-search-request.test.ts
Show resolved
Hide resolved
packages/headless/src/features/insight-search/insight-search-request.test.ts
Show resolved
Hide resolved
packages/headless/src/features/insight-search/insight-search-request.test.ts
Show resolved
Hide resolved
...s/headless/src/features/insight-search/legacy/insight-search-actions-thunk-processor.test.ts
Outdated
Show resolved
Hide resolved
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Very nice job 👍 well done! I liked the tests created on the thunk processor!
Please also manually test that the whole loop is properly working in the two code paths you modified:
|
1ddd2f8
to
4df88ea
Compare
723ba62
to
183dd70
Compare
packages/headless/src/controllers/insight/did-you-mean/headless-insight-did-you-mean.ts
Outdated
Show resolved
Hide resolved
export function buildDidYouMean(engine: InsightEngine): DidYouMean { | ||
export function buildDidYouMean( | ||
engine: InsightEngine, | ||
props: DidYouMeanProps = {} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
To avoid breaking changes, I would set the default value of props to {queryCorrectionMode: 'legacy'}
this client will not be switched from legacy
to next
automatically without their intervention.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not sure if we should set default value is 'legacy', if we enforce client to use new mode, then using 'next' is better. And we can document for user that if you upgrade, you need to update yours. Otherwise more and more user using 'legacy', it's not easy for us in the future to remove it
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Critical change to be made to the headless controller,
SFINT-5680
IN THIS PR:
1- We now allow the SAPI to automatically correct the queries that contain a typo.
This was done by specifying the parameter queryCorrection in the search request for the insight panel.
To support this in the Headless library we needed to update Insight Search Actions Thunk Processor by adding a new logic to the
processQueryCorrectionsOrContinue
that handles the query correction feature using the modern way instead of the classic way that consists of sending a whole new search query with the corrected query returned by the SAPI.In short: We now can correct with 1 request instead of 2.
2- Also added unit tests in headless to support this in the insight usecase
DEMO INSIGHT (queryCorrectionMode: 'next'):
Screen.Recording.2024-11-06.at.2.07.39.PM.mov
DEMO INSIGHT (queryCorrectionMode: 'legacy'):
legacy.insight.demo.auto.correct.mov
DEMO SEARCH (queryCorrectionMode: 'next'):
next.search.demo.auto.correct.mov
DEMO SEARCH (queryCorrectionMode: 'legacy'):
legacy.search.demo.auto.correct.mov
TESTS: